package com.cdty.chess.config;

import com.cdty.chess.model.CosProperties;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.region.Region;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 腾讯云COS配置类
 */
@Configuration
@RequiredArgsConstructor
public class CosConfig {

    private final CosProperties cosProperties;

    @Bean
    public COSClient cosClient() {
        var credentials = new BasicCOSCredentials(
            cosProperties.getSecretId(), 
            cosProperties.getSecretKey()
        );
        var clientConfig = new ClientConfig(new Region(cosProperties.getRegion()));
        return new COSClient(credentials, clientConfig);
    }
}